package com.cqc.advancetools;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by cui on 2017/8/9.
 */

public class LockActivity extends AppCompatActivity {

    @BindView(R.id.btn_lock)
    Button btnLock;
    @BindView(R.id.btn_un_lock)
    Button btnUnLock;
    @BindView(R.id.tv_app_number)
    TextView tvAppNumber;
    private FragmentManager fm;
    private LockFrag lockFrag;
    private UnLockFrag unLockFrag;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lock);
        ButterKnife.bind(this);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.colorAccent));
        }
        fm = getSupportFragmentManager();
        lockFrag = new LockFrag();
        unLockFrag = new UnLockFrag();
    }

    @OnClick({R.id.btn_lock, R.id.btn_un_lock})
    public void onClick(View view) {
        FragmentTransaction transaction=fm.beginTransaction();
        transaction.setCustomAnimations(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
        switch (view.getId()) {
            case R.id.btn_lock:
                transaction.replace(R.id.fl, lockFrag);
                Log.d("LogUtil","btn_lock");
                break;
            case R.id.btn_un_lock:
                transaction.replace(R.id.fl, unLockFrag);
                Log.d("LogUtil","btn_un_lock");
                break;
        }
        transaction.commit();
    }
}
